<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>修改区划信息</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="/assets/layui-v2.5.5/css/layui.css" media="all" />
	<link type="text/css" rel="stylesheet" href="/assets/tree/metroStyle.css">
	<style>
    .w-e-text-container {
        height: 320px !important;
    }
</style>
</head>
<body>
<div class="layui-fluid" style="margin-top:2%;">
		<form class="layui-form" action="" id="myForm">
		<div class="layui-form-item">
		    <label class="layui-form-label">名称<font color="#FF0000">*</font></label>
		    <div class="layui-input-block">
		      <input type="text" name="data.areaName" lay-verify="required" autocomplete="off" placeholder="请输入名称" class="layui-input">
		    </div>
		  </div>
		 <div class="layui-form-item">
				    <label class="layui-form-label">上级所属(必填项且只能选择一个)：<font color="#FF0000">*</font></label>
				    <div class="layui-input-inline">
						<textarea style="width: 200%;overflow:hidden;" class="layui-textarea"  type="text" lay-verify="required" id="mytextarea1" readonly></textarea>
				    </div>
				    </div> 
	       <div class="layui-form-item">
		    <label class="layui-form-label">排序</label>
		    <div class="layui-input-block">
		      <input type="text" name="data.sortOrder" autocomplete="off" placeholder="请输入排序(选填)" class="layui-input">
		    </div>
		  </div>
		    <div class="layui-form-item">
			    <label class="layui-form-label">负责人</label>
			    <div class="layui-input-block">
			      <input type="text" name="data.chargeMan" id="chargeman" autocomplete="off" placeholder="负责人需为注册账户(选填)" class="layui-input">
			    </div>
			  </div>
			   <div class="layui-form-item">
			    <label class="layui-form-label">负责人电话</label>
			    <div class="layui-input-block">
			      <input type="text" name="data.chargeMobile" id="chargemobile" autocomplete="off" placeholder="负责人电话需为注册账号(选填)" class="layui-input">
			    </div>
			  </div>
		  <div class="layui-form-item">
				<div class="layui-input-block" style="text-align: center;margin:0 auto;">
					<button class="layui-btn" lay-submit="" lay-filter="submit-area">保存</button> 
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>  
		</form>
	</div>
<script src="/assets/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="/assets/tree/jquery.ztree.all.js"></script>
<script type="text/javascript" src="/assets/tree/MultipleTreeSelect.js"></script>
<script src="/assets/layui-v2.5.5/layui.js" charset="utf-8"></script> 
<script>
var form,predata;
	predata=parent.mydata.data;
	predata = JSON.parse(predata);
	layui.use(['form'], function(){
	  form = layui.form;
	  zNodes=#(areas);
	defaults = {
	    zNodes: zNodes,
	    height:333
	}
$("#mytextarea1").attr("checks",predata.parentId);
$('input[name="data.areaName"]').val(predata.areaName);
$('input[name="data.sortOrder"]').val(predata.sortOrder);
$('input[name="data.chargeMan"]').val(predata.chargeMan);
$('input[name="data.chargeMobile"]').val(predata.chargeMobile);
	$("#mytextarea1").drawMultipleTree(defaults);
	    //重置按钮重置角色和单位
	      $(".layui-btn-primary").click(function(){
	      	$("#mytextarea1").text("");
	      });
		//提交表单
		form.on('submit(submit-area)', function(obj){					
			areaEdit(obj.field);
			return false;
			});
	});
function areaEdit(params){
	params.areaId=aaa;
	params.parentId=$('#mytextarea1').text();
	params.id=predata.id;
	$.ajax({
	    url : '/area/areaUpdate',
		type : "post",
		data : params,
		dataType : "json",
		success : function(ret) {
			if (ret.state == 'ok') {
				layer.msg(ret.msg, {icon: 1, offset: '15px', time: 600}, function(){
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
					parent.$(".layui-laypage-btn").click();
				});
			} else {
				layer.msg(ret.msg, {icon: 2, offset: '10px'});
			}
		},
		error: function() {
      } 
  });
}
</script> 
</body>
</html>